package base

import (
	"sync"
	"zinx/interfa"
)

var pack_once sync.Once

type pack_factory struct{}

var factoryInstance *pack_factory

// 生成不同的封包解包方式
func Factory() *pack_factory {
	pack_once.Do(func() {
		factoryInstance = new(pack_factory)
	})
	return factoryInstance
}

func (this *pack_factory) NewPack(kind string) interfa.IDataPack {
	var dataPack interfa.IDataPack

	switch kind {
	case interfa.ZinxDataPack:
		dataPack = NewDataPack()
		break
	// 添加自定义封包拆包方式
	default:
		dataPack = NewDataPack()
	}
	return dataPack
}
